!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/comment/continuecomment.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var i,o=t.listSelections(),r=[],a=0;a<o.length;a++){var l=o[a].head;if(!/\bcomment\b/.test(t.getTokenTypeAt(l)))return e.Pass;var s=t.getModeAt(l);if(i){if(i!=s)return e.Pass}else i=s;var c=null;if(i.blockCommentStart&&i.blockCommentContinue){var f,u=t.getLine(l.line).slice(0,l.ch),d=u.lastIndexOf(i.blockCommentEnd);if(-1!=d&&d==l.ch-i.blockCommentEnd.length);else if((f=u.lastIndexOf(i.blockCommentStart))>-1&&f>d){if(c=u.slice(0,f),/\S/.test(c)){c="";for(var h=0;h<f;++h)c+=" "}}else(f=u.indexOf(i.blockCommentContinue))>-1&&!/\S/.test(u.slice(0,f))&&(c=u.slice(0,f));null!=c&&(c+=i.blockCommentContinue)}if(null==c&&i.lineComment&&n(t)){var u=t.getLine(l.line),f=u.indexOf(i.lineComment);f>-1&&(c=u.slice(0,f),/\S/.test(c)?c=null:c+=i.lineComment+u.slice(f+i.lineComment.length).match(/^\s*/)[0])}if(null==c)return e.Pass;r[a]="\n"+c}t.operation(function(){for(var e=o.length-1;e>=0;e--)t.replaceRange(r[e],o[e].from(),o[e].to(),"+insert")})}function n(e){var t=e.getOption("continueComments");return!t||"object"!=typeof t||!1!==t.continueLineComment}e.defineOption("continueComments",null,function(n,i,o){if(o&&o!=e.Init&&n.removeKeyMap("continueComment"),i){var r="Enter";"string"==typeof i?r=i:"object"==typeof i&&i.key&&(r=i.key);var a={name:"continueComment"};a[r]=t,n.addKeyMap(a)}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/closebrackets.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:d[t]}function n(e){for(var t=0;t<e.length;t++){var n=e.charAt(t),o="'"+n+"'";m[o]||(m[o]=i(n))}}function i(e){return function(t){return s(t,e)}}function o(e){var t=e.state.closeBrackets;return!t||t.override?t:e.getModeAt(e.getCursor()).closeBrackets||t}function r(n){var i=o(n);if(!i||n.getOption("disableInput"))return e.Pass;for(var r=t(i,"pairs"),a=n.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var s=f(n,a[l].head);if(!s||r.indexOf(s)%2!=0)return e.Pass}for(var l=a.length-1;l>=0;l--){var c=a[l].head;n.replaceRange("",h(c.line,c.ch-1),h(c.line,c.ch+1),"+delete")}}function a(n){var i=o(n),r=i&&t(i,"explode");if(!r||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return e.Pass;var s=f(n,a[l].head);if(!s||r.indexOf(s)%2!=0)return e.Pass}n.operation(function(){var e=n.lineSeparator()||"\n";n.replaceSelection(e+e,null),n.execCommand("goCharLeft"),a=n.listSelections();for(var t=0;t<a.length;t++){var i=a[t].head.line;n.indentLine(i,null,!0),n.indentLine(i+1,null,!0)}})}function l(t){var n=e.cmpPos(t.anchor,t.head)>0;return{anchor:new h(t.anchor.line,t.anchor.ch+(n?-1:1)),head:new h(t.head.line,t.head.ch+(n?1:-1))}}function s(n,i){var r=o(n);if(!r||n.getOption("disableInput"))return e.Pass;var a=t(r,"pairs"),s=a.indexOf(i);if(-1==s)return e.Pass;for(var f,d=t(r,"triples"),m=a.charAt(s+1)==i,g=n.listSelections(),p=s%2==0,v=0;v<g.length;v++){var b,x=g[v],y=x.head,C=n.getRange(y,h(y.line,y.ch+1));if(p&&!x.empty())b="surround";else if(!m&&p||C!=i)if(m&&y.ch>1&&d.indexOf(i)>=0&&n.getRange(h(y.line,y.ch-2),y)==i+i&&(y.ch<=2||n.getRange(h(y.line,y.ch-3),h(y.line,y.ch-2))!=i))b="addFour";else if(m){var k=0==y.ch?" ":n.getRange(h(y.line,y.ch-1),y);if(e.isWordChar(C)||k==i||e.isWordChar(k))return e.Pass;b="both"}else{if(!p||n.getLine(y.line).length!=y.ch&&!c(C,a)&&!/\s/.test(C))return e.Pass;b="both"}else b=m&&u(n,y)?"both":d.indexOf(i)>=0&&n.getRange(y,h(y.line,y.ch+3))==i+i+i?"skipThree":"skip";if(f){if(f!=b)return e.Pass}else f=b}var L=s%2?a.charAt(s-1):i,S=s%2?i:a.charAt(s+1);n.operation(function(){if("skip"==f)n.execCommand("goCharRight");else if("skipThree"==f)for(var e=0;e<3;e++)n.execCommand("goCharRight");else if("surround"==f){for(var t=n.getSelections(),e=0;e<t.length;e++)t[e]=L+t[e]+S;n.replaceSelections(t,"around"),t=n.listSelections().slice();for(var e=0;e<t.length;e++)t[e]=l(t[e]);n.setSelections(t)}else"both"==f?(n.replaceSelection(L+S,null),n.triggerElectric(L+S),n.execCommand("goCharLeft")):"addFour"==f&&(n.replaceSelection(L+L+L+L,"before"),n.execCommand("goCharRight"))})}function c(e,t){var n=t.lastIndexOf(e);return n>-1&&n%2==1}function f(e,t){var n=e.getRange(h(t.line,t.ch-1),h(t.line,t.ch+1));return 2==n.length?n:null}function u(e,t){var n=e.getTokenAt(h(t.line,t.ch+1));return/\bstring/.test(n.type)&&n.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}var d={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},h=e.Pos;e.defineOption("autoCloseBrackets",!1,function(i,o,r){r&&r!=e.Init&&(i.removeKeyMap(m),i.state.closeBrackets=null),o&&(n(t(o,"pairs")),i.state.closeBrackets=o,i.addKeyMap(m))});var m={Backspace:r,Enter:a};n(d.pairs+"`")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/xml-fold",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line-t.line||e.ch-t.ch}function n(e,t,n,i){this.line=t,this.ch=n,this.cm=e,this.text=e.getLine(t),this.min=i?Math.max(i.from,e.firstLine()):e.firstLine(),this.max=i?Math.min(i.to-1,e.lastLine()):e.lastLine()}function i(e,t){var n=e.cm.getTokenTypeAt(d(e.line,t));return n&&/\btag\b/.test(n)}function o(e){if(!(e.line>=e.max))return e.ch=0,e.text=e.cm.getLine(++e.line),!0}function r(e){if(!(e.line<=e.min))return e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(o(e))continue;return}{if(i(e,t+1)){var n=e.text.lastIndexOf("/",t),r=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,r?"selfClose":"regular"}e.ch=t+1}}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(r(e))continue;return}if(i(e,t+1)){m.lastIndex=t,e.ch=t;var n=m.exec(e.text);if(n&&n.index==t)return n}else e.ch=t}}function s(e){for(;;){m.lastIndex=e.ch;var t=m.exec(e.text);if(!t){if(o(e))continue;return}{if(i(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(r(e))continue;return}{if(i(e,t+1)){var n=e.text.lastIndexOf("/",t),o=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,o?"selfClose":"regular"}e.ch=t}}}function f(e,t){for(var n=[];;){var i,o=s(e),r=e.line,l=e.ch-(o?o[0].length:0);if(!o||!(i=a(e)))return;if("selfClose"!=i)if(o[1]){for(var c=n.length-1;c>=0;--c)if(n[c]==o[2]){n.length=c;break}if(c<0&&(!t||t==o[2]))return{tag:o[2],from:d(r,l),to:d(e.line,e.ch)}}else n.push(o[2])}}function u(e,t){for(var n=[];;){var i=c(e);if(!i)return;if("selfClose"!=i){var o=e.line,r=e.ch,a=l(e);if(!a)return;if(a[1])n.push(a[2]);else{for(var s=n.length-1;s>=0;--s)if(n[s]==a[2]){n.length=s;break}if(s<0&&(!t||t==a[2]))return{tag:a[2],from:d(e.line,e.ch),to:d(o,r)}}}else l(e)}}var d=e.Pos,h="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",m=new RegExp("<(/?)(["+h+"][A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");e.registerHelper("fold","xml",function(e,t){for(var i=new n(e,t.line,0);;){var o,r=s(i);if(!r||i.line!=t.line||!(o=a(i)))return;if(!r[1]&&"selfClose"!=o){var l=d(i.line,i.ch),c=f(i,r[2]);return c&&{from:l,to:c.from}}}}),e.findMatchingTag=function(e,i,o){var r=new n(e,i.line,i.ch,o);if(-1!=r.text.indexOf(">")||-1!=r.text.indexOf("<")){var s=a(r),c=s&&d(r.line,r.ch),h=s&&l(r);if(s&&h&&!(t(r,i)>0)){var m={from:d(r.line,r.ch),to:c,tag:h[2]};return"selfClose"==s?{open:m,close:null,at:"open"}:h[1]?{open:u(r,h[2]),close:m,at:"close"}:(r=new n(e,c.line,c.ch,o),{open:m,close:f(r,h[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,i,o){for(var r=new n(e,t.line,t.ch,i);;){var a=u(r,o);if(!a)break;var l=new n(e,t.line,t.ch,i),s=f(l,a.tag);if(s)return{open:a,close:s}}},e.scanForClosingTag=function(e,t,i,o){return f(new n(e,t.line,t.ch,o?{from:0,to:o}:null),i)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define("addon/edit/closetag.js",["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var n=t.listSelections(),i=[],s=t.getOption("autoCloseTags"),c=0;c<n.length;c++){if(!n[c].empty())return e.Pass;var f=n[c].head,u=t.getTokenAt(f),d=e.innerMode(t.getMode(),u.state),h=d.state;if("xml"!=d.mode.name||!h.tagName)return e.Pass;var m="html"==d.mode.configuration,g="object"==typeof s&&s.dontCloseTags||m&&a,p="object"==typeof s&&s.indentTags||m&&l,v=h.tagName;u.end>f.ch&&(v=v.slice(0,v.length-u.end+f.ch));var b=v.toLowerCase();if(!v||"string"==u.type&&(u.end!=f.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||1==u.string.length)||"tag"==u.type&&"closeTag"==h.type||u.string.indexOf("/")==u.string.length-1||g&&o(g,b)>-1||r(t,v,f,h,!0))return e.Pass;var x=p&&o(p,b)>-1;i[c]={indent:x,text:">"+(x?"\n\n":"")+"</"+v+">",newPos:x?e.Pos(f.line+1,0):e.Pos(f.line,f.ch+1)}}for(var y="object"==typeof s&&s.dontIndentOnAutoClose,c=n.length-1;c>=0;c--){var C=i[c];t.replaceRange(C.text,n[c].head,n[c].anchor,"+insert");var k=t.listSelections().slice(0);k[c]={head:C.newPos,anchor:C.newPos},t.setSelections(k),!y&&C.indent&&(t.indentLine(C.newPos.line,null,!0),t.indentLine(C.newPos.line+1,null,!0))}}function n(t,n){for(var i=t.listSelections(),o=[],a=n?"/":"</",l=t.getOption("autoCloseTags"),s="object"==typeof l&&l.dontIndentOnSlash,c=0;c<i.length;c++){if(!i[c].empty())return e.Pass;var f=i[c].head,u=t.getTokenAt(f),d=e.innerMode(t.getMode(),u.state),h=d.state;if(n&&("string"==u.type||"<"!=u.string.charAt(0)||u.start!=f.ch-1))return e.Pass;var m;if("xml"!=d.mode.name)if("htmlmixed"==t.getMode().name&&"javascript"==d.mode.name)m=a+"script";else{if("htmlmixed"!=t.getMode().name||"css"!=d.mode.name)return e.Pass;m=a+"style"}else{if(!h.context||!h.context.tagName||r(t,h.context.tagName,f,h))return e.Pass;m=a+h.context.tagName}">"!=t.getLine(f.line).charAt(u.end)&&(m+=">"),o[c]=m}if(t.replaceSelections(o),i=t.listSelections(),!s)for(var c=0;c<i.length;c++)(c==i.length-1||i[c].head.line<i[c+1].head.line)&&t.indentLine(i[c].head.line)}function i(t){return t.getOption("disableInput")?e.Pass:n(t,!0)}function o(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,i=e.length;n<i;++n)if(e[n]==t)return n;return-1}function r(t,n,i,o,r){if(!e.scanForClosingTag)return!1;var a=Math.min(t.lastLine()+1,i.line+500),l=e.scanForClosingTag(t,i,null,a);if(!l||l.tag!=n)return!1;for(var s=o.context,c=r?1:0;s&&s.tagName==n;s=s.prev)++c;i=l.to;for(var f=1;f<c;f++){var u=e.scanForClosingTag(t,i,null,a);if(!u||u.tag!=n)return!1;i=u.to}return!0}e.defineOption("autoCloseTags",!1,function(n,o,r){if(r!=e.Init&&r&&n.removeKeyMap("autoCloseTags"),o){var a={name:"autoCloseTags"};("object"!=typeof o||o.whenClosing)&&(a["'/'"]=function(e){return i(e)}),("object"!=typeof o||o.whenOpening)&&(a["'>'"]=function(e){return t(e)}),n.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return n(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/matchbrackets.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,i){var o=e.getLineHandle(t.line),r=t.ch-1,s=i&&i.afterCursor;null==s&&(s=/(^| )cm-fat-cursor($| )/.test(e.getWrapperElement().className));var c=!s&&r>=0&&l[o.text.charAt(r)]||l[o.text.charAt(++r)];if(!c)return null;var f=">"==c.charAt(1)?1:-1;if(i&&i.strict&&f>0!=(r==t.ch))return null;var u=e.getTokenTypeAt(a(t.line,r+1)),d=n(e,a(t.line,r+(f>0?1:0)),f,u||null,i);return null==d?null:{from:a(t.line,r),to:d&&d.pos,match:d&&d.ch==c.charAt(0),forward:f>0}}function n(e,t,n,i,o){for(var r=o&&o.maxScanLineLength||1e4,s=o&&o.maxScanLines||1e3,c=[],f=o&&o.bracketRegex?o.bracketRegex:/[(){}[\]]/,u=n>0?Math.min(t.line+s,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-s),d=t.line;d!=u;d+=n){var h=e.getLine(d);if(h){var m=n>0?0:h.length-1,g=n>0?h.length:-1;if(!(h.length>r))for(d==t.line&&(m=t.ch-(n<0?1:0));m!=g;m+=n){var p=h.charAt(m);if(f.test(p)&&(void 0===i||e.getTokenTypeAt(a(d,m+1))==i)){var v=l[p];if(">"==v.charAt(1)==n>0)c.push(p);else{if(!c.length)return{pos:a(d,m),ch:p};c.pop()}}}}}return d-n!=(n>0?e.lastLine():e.firstLine())&&null}function i(e,n,i){for(var o=e.state.matchBrackets.maxHighlightLineLength||1e3,l=[],s=e.listSelections(),c=0;c<s.length;c++){var f=s[c].empty()&&t(e,s[c].head,i);if(f&&e.getLine(f.from.line).length<=o){var u=f.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket";l.push(e.markText(f.from,a(f.from.line,f.from.ch+1),{className:u})),f.to&&e.getLine(f.to.line).length<=o&&l.push(e.markText(f.to,a(f.to.line,f.to.ch+1),{className:u}))}}if(l.length){r&&e.state.focused&&e.focus();var d=function(){e.operation(function(){for(var e=0;e<l.length;e++)l[e].clear()})};if(!n)return d;setTimeout(d,800)}}function o(e){e.operation(function(){s&&(s(),s=null),s=i(e,!1,e.state.matchBrackets)})}var r=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||document.documentMode<8),a=e.Pos,l={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},s=null;e.defineOption("matchBrackets",!1,function(t,n,i){i&&i!=e.Init&&(t.off("cursorActivity",o),s&&(s(),s=null)),n&&(t.state.matchBrackets="object"==typeof n?n:{},t.on("cursorActivity",o))}),e.defineExtension("matchBrackets",function(){i(this,!0)}),e.defineExtension("findMatchingBracket",function(e,n,i){return(i||"boolean"==typeof n)&&(i?(i.strict=n,n=i):n=n?{strict:!0}:null),t(this,e,n)}),e.defineExtension("scanForBracket",function(e,t,i,o){return n(this,e,t,i,o)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define("addon/edit/matchtags.js",["../../lib/codemirror","../fold/xml-fold"],e):e(CodeMirror)}(function(e){"use strict";function t(e){e.state.tagHit&&e.state.tagHit.clear(),e.state.tagOther&&e.state.tagOther.clear(),e.state.tagHit=e.state.tagOther=null}function n(n){n.state.failedTagMatch=!1,n.operation(function(){if(t(n),!n.somethingSelected()){var i=n.getCursor(),o=n.getViewport();o.from=Math.min(o.from,i.line),o.to=Math.max(i.line+1,o.to);var r=e.findMatchingTag(n,i,o);if(r){if(n.state.matchBothTags){var a="open"==r.at?r.open:r.close;a&&(n.state.tagHit=n.markText(a.from,a.to,{className:"CodeMirror-matchingtag"}))}var l="close"==r.at?r.open:r.close;l?n.state.tagOther=n.markText(l.from,l.to,{className:"CodeMirror-matchingtag"}):n.state.failedTagMatch=!0}}})}function i(e){e.state.failedTagMatch&&n(e)}e.defineOption("matchTags",!1,function(o,r,a){a&&a!=e.Init&&(o.off("cursorActivity",n),o.off("viewportChange",i),t(o)),r&&(o.state.matchBothTags="object"==typeof r&&r.bothTags,o.on("cursorActivity",n),o.on("viewportChange",i),n(o))}),e.commands.toMatchingTag=function(t){var n=e.findMatchingTag(t,t.getCursor());if(n){var i="close"==n.at?n.open:n.close;i&&t.extendSelection(i.to,i.from)}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/edit/trailingspace.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineOption("showTrailingSpace",!1,function(t,n,i){i==e.Init&&(i=!1),i&&!n?t.removeOverlay("trailingspace"):!i&&n&&t.addOverlay({token:function(e){for(var t=e.string.length,n=t;n&&/\s/.test(e.string.charAt(n-1));--n);return n>e.pos?(e.pos=n,null):(e.pos=t,"trailingspace")},name:"trailingspace"})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/foldcode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,o,r,a){function l(e){var n=s(t,o);if(!n||n.to.line-n.from.line<c)return null;for(var i=t.findMarksAt(n.from),r=0;r<i.length;++r)if(i[r].__isFold&&"fold"!==a){if(!e)return null;n.cleared=!0,i[r].clear()}return n}if(r&&r.call){var s=r;r=null}else var s=i(t,r,"rangeFinder");"number"==typeof o&&(o=e.Pos(o,0));var c=i(t,r,"minFoldSize"),f=l(!0);if(i(t,r,"scanUp"))for(;!f&&o.line>t.firstLine();)o=e.Pos(o.line-1,0),f=l(!1);if(f&&!f.cleared&&"unfold"!==a){var u=n(t,r);e.on(u,"mousedown",function(t){d.clear(),e.e_preventDefault(t)});var d=t.markText(f.from,f.to,{replacedWith:u,clearOnEnter:i(t,r,"clearOnEnter"),__isFold:!0});d.on("clear",function(n,i){e.signal(t,"unfold",t,n,i)}),e.signal(t,"fold",t,f.from,f.to)}}function n(e,t){var n=i(e,t,"widget");if("string"==typeof n){var o=document.createTextNode(n);n=document.createElement("span"),n.appendChild(o),n.className="CodeMirror-foldmarker"}else n&&(n=n.cloneNode(!0));return n}function i(e,t,n){if(t&&void 0!==t[n])return t[n];var i=e.options.foldOptions;return i&&void 0!==i[n]?i[n]:o[n]}e.newFoldFunction=function(e,n){return function(i,o){t(i,o,{rangeFinder:e,widget:n})}},e.defineExtension("foldCode",function(e,n,i){t(this,e,n,i)}),e.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),n=0;n<t.length;++n)if(t[n].__isFold)return!0}),e.commands.toggleFold=function(e){e.foldCode(e.getCursor())},e.commands.fold=function(e){e.foldCode(e.getCursor(),null,"fold")},e.commands.unfold=function(e){e.foldCode(e.getCursor(),null,"unfold")},e.commands.foldAll=function(t){t.operation(function(){for(var n=t.firstLine(),i=t.lastLine();n<=i;n++)t.foldCode(e.Pos(n,0),null,"fold")})},e.commands.unfoldAll=function(t){t.operation(function(){for(var n=t.firstLine(),i=t.lastLine();n<=i;n++)t.foldCode(e.Pos(n,0),null,"unfold")})},e.registerHelper("fold","combine",function(){var e=Array.prototype.slice.call(arguments,0);return function(t,n){for(var i=0;i<e.length;++i){var o=e[i](t,n);if(o)return o}}}),e.registerHelper("fold","auto",function(e,t){for(var n=e.getHelpers(t,"fold"),i=0;i<n.length;i++){var o=n[i](e,t);if(o)return o}});var o={rangeFinder:e.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1,clearOnEnter:!0};e.defineOption("foldOptions",null),e.defineExtension("foldOption",function(e,t){return i(this,e,t)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define("addon/fold/foldgutter.js",["../../lib/codemirror","./foldcode"],e):e(CodeMirror)}(function(e){"use strict";function t(e){this.options=e,this.from=this.to=0}function n(e){return!0===e&&(e={}),null==e.gutter&&(e.gutter="CodeMirror-foldgutter"),null==e.indicatorOpen&&(e.indicatorOpen="CodeMirror-foldgutter-open"),null==e.indicatorFolded&&(e.indicatorFolded="CodeMirror-foldgutter-folded"),e}function i(e,t){for(var n=e.findMarks(u(t,0),u(t+1,0)),i=0;i<n.length;++i)if(n[i].__isFold&&n[i].find().from.line==t)return n[i]}function o(e){if("string"==typeof e){var t=document.createElement("div");return t.className=e+" CodeMirror-guttermarker-subtle",t}return e.cloneNode(!0)}function r(e,t,n){var r=e.state.foldGutter.options,a=t,l=e.foldOption(r,"minFoldSize"),s=e.foldOption(r,"rangeFinder");e.eachLine(t,n,function(t){var n=null;if(i(e,a))n=o(r.indicatorFolded);else{var c=u(a,0),f=s&&s(e,c);f&&f.to.line-f.from.line>=l&&(n=o(r.indicatorOpen))}e.setGutterMarker(t,r.gutter,n),++a})}function a(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation(function(){r(e,t.from,t.to)}),n.from=t.from,n.to=t.to)}function l(e,t,n){var o=e.state.foldGutter;if(o){var r=o.options;if(n==r.gutter){var a=i(e,t);a?a.clear():e.foldCode(u(t,0),r.rangeFinder)}}}function s(e){var t=e.state.foldGutter;if(t){var n=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){a(e)},n.foldOnChangeTimeSpan||600)}}function c(e){var t=e.state.foldGutter;if(t){var n=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var n=e.getViewport();t.from==t.to||n.from-t.to>20||t.from-n.to>20?a(e):e.operation(function(){n.from<t.from&&(r(e,n.from,t.from),t.from=n.from),n.to>t.to&&(r(e,t.to,n.to),t.to=n.to)})},n.updateViewportTimeSpan||400)}}function f(e,t){var n=e.state.foldGutter;if(n){var i=t.line;i>=n.from&&i<n.to&&r(e,i,i+1)}}e.defineOption("foldGutter",!1,function(i,o,r){r&&r!=e.Init&&(i.clearGutter(i.state.foldGutter.options.gutter),i.state.foldGutter=null,i.off("gutterClick",l),i.off("change",s),i.off("viewportChange",c),i.off("fold",f),i.off("unfold",f),i.off("swapDoc",s)),o&&(i.state.foldGutter=new t(n(o)),a(i),i.on("gutterClick",l),i.on("change",s),i.on("viewportChange",c),i.on("fold",f),i.on("unfold",f),i.on("swapDoc",s))});var u=e.Pos}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/brace-fold.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerHelper("fold","brace",function(t,n){function i(i){for(var l=n.ch,s=0;;){var c=l<=0?-1:a.lastIndexOf(i,l-1);if(-1!=c){if(1==s&&c<n.ch)break;if(o=t.getTokenTypeAt(e.Pos(r,c+1)),!/^(comment|string)/.test(o))return c+1;l=c-1}else{if(1==s)break;s=1,l=a.length}}}var o,r=n.line,a=t.getLine(r),l="{",s="}",c=i("{");if(null==c&&(l="[",s="]",c=i("[")),null!=c){var f,u,d=1,h=t.lastLine();e:for(var m=r;m<=h;++m)for(var g=t.getLine(m),p=m==r?c:0;;){var v=g.indexOf(l,p),b=g.indexOf(s,p);if(v<0&&(v=g.length),b<0&&(b=g.length),(p=Math.min(v,b))==g.length)break;if(t.getTokenTypeAt(e.Pos(m,p+1))==o)if(p==v)++d;else if(!--d){f=m,u=p;break e}++p}if(null!=f&&(r!=f||u!=c))return{from:e.Pos(r,c),to:e.Pos(f,u)}}}),e.registerHelper("fold","import",function(t,n){function i(n){if(n<t.firstLine()||n>t.lastLine())return null;var i=t.getTokenAt(e.Pos(n,1));if(/\S/.test(i.string)||(i=t.getTokenAt(e.Pos(n,i.end+1))),"keyword"!=i.type||"import"!=i.string)return null;for(var o=n,r=Math.min(t.lastLine(),n+10);o<=r;++o){var a=t.getLine(o),l=a.indexOf(";");if(-1!=l)return{startCh:i.end,end:e.Pos(o,l)}}}var o,r=n.line,a=i(r);if(!a||i(r-1)||(o=i(r-2))&&o.end.line==r-1)return null;for(var l=a.end;;){var s=i(l.line+1);if(null==s)break;l=s.end}return{from:t.clipPos(e.Pos(r,a.startCh+1)),to:l}}),e.registerHelper("fold","include",function(t,n){function i(n){if(n<t.firstLine()||n>t.lastLine())return null;var i=t.getTokenAt(e.Pos(n,1));return/\S/.test(i.string)||(i=t.getTokenAt(e.Pos(n,i.end+1))),"meta"==i.type&&"#include"==i.string.slice(0,8)?i.start+8:void 0}var o=n.line,r=i(o);if(null==r||null!=i(o-1))return null;for(var a=o;;){if(null==i(a+1))break;++a}return{from:e.Pos(o,r+1),to:t.clipPos(e.Pos(a))}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/comment-fold.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.registerGlobalHelper("fold","comment",function(e){return e.blockCommentStart&&e.blockCommentEnd},function(t,n){var i=t.getModeAt(n),o=i.blockCommentStart,r=i.blockCommentEnd;if(o&&r){for(var a,l=n.line,s=t.getLine(l),c=n.ch,f=0;;){var u=c<=0?-1:s.lastIndexOf(o,c-1);if(-1!=u){if(1==f&&u<n.ch)return;if(/comment/.test(t.getTokenTypeAt(e.Pos(l,u+1)))&&(0==u||s.slice(u-r.length,u)==r||!/comment/.test(t.getTokenTypeAt(e.Pos(l,u))))){a=u+o.length;break}c=u-1}else{if(1==f)return;f=1,c=s.length}}var d,h,m=1,g=t.lastLine();e:for(var p=l;p<=g;++p)for(var v=t.getLine(p),b=p==l?a:0;;){var x=v.indexOf(o,b),y=v.indexOf(r,b);if(x<0&&(x=v.length),y<0&&(y=v.length),(b=Math.min(x,y))==v.length)break;if(b==x)++m;else if(!--m){d=p,h=b;break e}++b}if(null!=d&&(l!=d||h!=a))return{from:e.Pos(l,a),to:e.Pos(d,h)}}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/fold/indent-fold.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,n){var i=t.getLine(n),o=i.search(/\S/);return-1==o||/\bcomment\b/.test(t.getTokenTypeAt(e.Pos(n,o+1)))?-1:e.countColumn(i,null,t.getOption("tabSize"))}e.registerHelper("fold","indent",function(n,i){var o=t(n,i.line);if(!(o<0)){for(var r=null,a=i.line+1,l=n.lastLine();a<=l;++a){var s=t(n,a);if(-1==s);else{if(!(s>o))break;r=a}}return r?{from:e.Pos(i.line,n.getLine(i.line).length),to:e.Pos(r,n.getLine(r).length)}:void 0}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/format/autoFormatAll.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineExtension("autoFormatAll",function(t,n){function i(){c+="\n",u=!0,++f}for(var o=this,r=o.getMode(),a=o.getRange(t,n).split("\n"),l=e.copyState(r,o.getTokenAt(t).state),s=o.getOption("tabSize"),c="",f=0,u=0==t.ch,d=0;d<a.length;++d){for(var h=new e.StringStream(a[d],s);!h.eol();){var m=e.innerMode(r,l),g=r.token(h,l),p=h.current();h.start=h.pos,u&&!/\S/.test(p)||(c+=p,u=!1),!u&&m.mode.newlineAfterToken&&m.mode.newlineAfterToken(g,p,h.string.slice(h.pos)||a[d+1]||"",m.state)&&i()}!h.pos&&r.blankLine&&r.blankLine(l),!u&&d<a.length-1&&i()}o.operation(function(){o.replaceRange(c,t,n);for(var e=t.line+1,i=t.line+f;e<=i;++e)o.indentLine(e,"smart");o.setCursor({line:0,ch:0})})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/format/formatting.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e){for(var t=[/for\s*?\((.*?)\)/g,/&#?[a-z0-9]+;[\s\S]/g,/\"(.*?)((\")|$)/g,/\/\*(.*?)(\*\/|$)/g,/^\/\/.*/g],n=[],i=0;i<t.length;i++)for(var o=0;o<e.length;){var r=e.substr(o).match(t[i]);if(null==r)break;n.push({start:o+r.index,end:o+r.index+r[0].length}),o+=r.index+Math.max(1,r[0].length)}return n.sort(function(e,t){return e.start-t.start}),n}e.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(e,t){return/^[;{}]$/.test(t)}}),e.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",wordWrapChars:[";","\\{","\\}"],autoFormatLineBreaks:function(e){var n=0,i=this.jsonMode?function(e){return e.replace(/([,{])/g,"$1\n").replace(/}/g,"\n}")}:function(e){return e.replace(/(;|\{|\})([^\r\n;])/g,"$1\n$2")},o=t(e),r="";if(null!=o){for(var a=0;a<o.length;a++)o[a].start>n&&(r+=i(e.substring(n,o[a].start)),n=o[a].start),o[a].start<=n&&o[a].end>=n&&(r+=e.substring(n,o[a].end),n=o[a].end);n<e.length&&(r+=i(e.substr(n)))}else r=i(e);return r.replace(/^\n*|\n*$/,"")}});e.extendMode("xml",{commentStart:"\x3c!--",commentEnd:"--\x3e",noBreak:!1,noBreakEmpty:null,tagType:"",tagName:"",isXML:!1,newlineAfterToken:function(e,t,n,i){var o="a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u",r="label|li|option|textarea|title|"+o,a=!1,l=null,s="";if(this.isXML="xml"==this.configuration,"comment"==e||/<!--/.test(n))return!1;if("tag"==e){if(0==t.indexOf("<")&&0==!t.indexOf("</")){this.tagType="open",l=t.match(/^<\s*?([\w]+?)$/i),this.tagName=null!=l?l[1]:"";var s=this.tagName.toLowerCase();-1!=("|"+r+"|").indexOf("|"+s+"|")&&(this.noBreak=!0)}if(0==t.indexOf(">")&&"open"==this.tagType){this.tagType="";var c=this.isXML?"[^<]*?":"";return RegExp("^"+c+"</s*?"+this.tagName+"s*?>","i").test(n)?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(a=this.noBreak,this.noBreak=!1,!a)}if(0==t.indexOf("</")&&(this.tagType="close",l=t.match(/^<\/\s*?([\w]+?)$/i),null!=l&&(s=l[1].toLowerCase()),-1!=("|"+o+"|").indexOf("|"+s+"|")&&(this.noBreak=!0)),0==t.indexOf(">")&&"close"==this.tagType)return this.tagType="",0==n.indexOf("<")&&(l=n.match(/^<\/?\s*?([\w]+?)(\s|>)/i),s=null!=l?l[1].toLowerCase():"",-1==("|"+r+"|").indexOf("|"+s+"|"))?(this.noBreak=!1,!0):(a=this.noBreak,this.noBreak=!1,!a)}return 0==n.indexOf("<")&&(this.noBreak=!1,this.isXML&&""!=this.tagName?(this.tagName="",!1):(l=n.match(/^<\/?\s*?([\w]+?)(\s|>)/i),s=null!=l?l[1].toLowerCase():"",-1==("|"+r+"|").indexOf("|"+s+"|")))}}),e.defineExtension("commentRange",function(t,n,i){var o=this,r=e.innerMode(o.getMode(),o.getTokenAt(n).state).mode;o.operation(function(){if(t)o.replaceRange(r.commentEnd,i),o.replaceRange(r.commentStart,n),o.setSelection(n,{line:i.line,ch:i.ch+r.commentStart.length+r.commentEnd.length}),n.line==i.line&&n.ch==i.ch&&o.setCursor(n.line,n.ch+r.commentStart.length);else{var e=o.getRange(n,i),a=e.indexOf(r.commentStart),l=e.lastIndexOf(r.commentEnd);a>-1&&l>-1&&l>a&&(e=e.substr(0,a)+e.substring(a+r.commentStart.length,l)+e.substr(l+r.commentEnd.length)),o.replaceRange(e,n,i),o.setSelection(n,{line:i.line,ch:i.ch-r.commentStart.length-r.commentEnd.length})}})}),e.defineExtension("autoIndentRange",function(e,t){var n=this;this.operation(function(){for(var i=e.line;i<=t.line;i++)n.indentLine(i,"smart")})}),e.defineExtension("autoFormatRange",function(t,n){function i(){c+="\n",u=!0,++f}for(var o=this,r=o.getMode(),a=o.getRange(t,n).split("\n"),l=e.copyState(r,o.getTokenAt(t).state),s=o.getOption("tabSize"),c="",f=0,u=0==t.ch,d=0;d<a.length;++d){for(var h=new e.StringStream(a[d],s);!h.eol();){var m=e.innerMode(r,l),g=r.token(h,l),p=h.current();h.start=h.pos,u&&!/\S/.test(p)||(c+=p,u=!1),!u&&m.mode.newlineAfterToken&&m.mode.newlineAfterToken(g,p,h.string.slice(h.pos)||a[d+1]||"",m.state)&&i()}!h.pos&&r.blankLine&&r.blankLine(l),!u&&d<a.length-1&&i()}o.operation(function(){o.replaceRange(c,t,n);for(var e=t.line+1,i=t.line+f;e<=i;++e)o.indentLine(e,"smart");o.setSelection(t,o.getCursor(!1))})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/selection/active-line.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){for(var t=0;t<e.state.activeLines.length;t++)e.removeLineClass(e.state.activeLines[t],"wrap",r),e.removeLineClass(e.state.activeLines[t],"background",a),e.removeLineClass(e.state.activeLines[t],"gutter",l)}function n(e,t){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function i(e,i){for(var o=[],s=0;s<i.length;s++){var c=i[s],f=e.getOption("styleActiveLine");if("object"==typeof f&&f.nonEmpty?c.anchor.line==c.head.line:c.empty()){var u=e.getLineHandleVisualStart(c.head.line);o[o.length-1]!=u&&o.push(u)}}n(e.state.activeLines,o)||e.operation(function(){t(e);for(var n=0;n<o.length;n++)e.addLineClass(o[n],"wrap",r),e.addLineClass(o[n],"background",a),e.addLineClass(o[n],"gutter",l);e.state.activeLines=o})}function o(e,t){i(e,t.ranges)}var r="CodeMirror-activeline",a="CodeMirror-activeline-background",l="CodeMirror-activeline-gutter";e.defineOption("styleActiveLine",!1,function(n,r,a){var l=a!=e.Init&&a;r!=l&&(l&&(n.off("beforeSelectionChange",o),t(n),delete n.state.activeLines),r&&(n.state.activeLines=[],i(n,n.listSelections()),n.on("beforeSelectionChange",o)))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/search/searchcursor",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){var t=e.flags;return null!=t?t:(e.ignoreCase?"i":"")+(e.global?"g":"")+(e.multiline?"m":"")}function n(e){
return e.global?e:new RegExp(e.source,t(e)+"g")}function i(e){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source)}function o(e,t,i){t=n(t);for(var o=i.line,r=i.ch,a=e.lastLine();o<=a;o++,r=0){t.lastIndex=r;var l=e.getLine(o),s=t.exec(l);if(s)return{from:g(o,s.index),to:g(o,s.index+s[0].length),match:s}}}function r(e,t,r){if(!i(t))return o(e,t,r);t=n(t);for(var a,l=1,s=r.line,c=e.lastLine();s<=c;){for(var f=0;f<l;f++){var u=e.getLine(s++);a=null==a?u:a+"\n"+u}l*=2,t.lastIndex=r.ch;var d=t.exec(a);if(d){var h=a.slice(0,d.index).split("\n"),m=d[0].split("\n"),p=r.line+h.length-1,v=h[h.length-1].length;return{from:g(p,v),to:g(p+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:d}}}}function a(e,t){for(var n,i=0;;){t.lastIndex=i;var o=t.exec(e);if(!o)return n;if(n=o,(i=n.index+(n[0].length||1))==e.length)return n}}function l(e,t,i){t=n(t);for(var o=i.line,r=i.ch,l=e.firstLine();o>=l;o--,r=-1){var s=e.getLine(o);r>-1&&(s=s.slice(0,r));var c=a(s,t);if(c)return{from:g(o,c.index),to:g(o,c.index+c[0].length),match:c}}}function s(e,t,i){t=n(t);for(var o,r=1,l=i.line,s=e.firstLine();l>=s;){for(var c=0;c<r;c++){var f=e.getLine(l--);o=null==o?f.slice(0,i.ch):f+"\n"+o}r*=2;var u=a(o,t);if(u){var d=o.slice(0,u.index).split("\n"),h=u[0].split("\n"),m=l+d.length,p=d[d.length-1].length;return{from:g(m,p),to:g(m+h.length-1,1==h.length?p+h[0].length:h[h.length-1].length),match:u}}}}function c(e,t,n,i){if(e.length==t.length)return n;for(var o=0,r=n+Math.max(0,e.length-t.length);;){if(o==r)return o;var a=o+r>>1,l=i(e.slice(0,a)).length;if(l==n)return a;l>n?r=a:o=a+1}}function f(e,t,n,i){if(!t.length)return null;var o=i?h:m,r=o(t).split(/\r|\n\r?/);e:for(var a=n.line,l=n.ch,s=e.lastLine()+1-r.length;a<=s;a++,l=0){var f=e.getLine(a).slice(l),u=o(f);if(1==r.length){var d=u.indexOf(r[0]);if(-1==d)continue e;var n=c(f,u,d,o)+l;return{from:g(a,c(f,u,d,o)+l),to:g(a,c(f,u,d+r[0].length,o)+l)}}var p=u.length-r[0].length;if(u.slice(p)==r[0]){for(var v=1;v<r.length-1;v++)if(o(e.getLine(a+v))!=r[v])continue e;var b=e.getLine(a+r.length-1),x=o(b),y=r[r.length-1];if(x.slice(0,y.length)==y)return{from:g(a,c(f,u,p,o)+l),to:g(a+r.length-1,c(b,x,y.length,o))}}}}function u(e,t,n,i){if(!t.length)return null;var o=i?h:m,r=o(t).split(/\r|\n\r?/);e:for(var a=n.line,l=n.ch,s=e.firstLine()-1+r.length;a>=s;a--,l=-1){var f=e.getLine(a);l>-1&&(f=f.slice(0,l));var u=o(f);if(1==r.length){var d=u.lastIndexOf(r[0]);if(-1==d)continue e;return{from:g(a,c(f,u,d,o)),to:g(a,c(f,u,d+r[0].length,o))}}var p=r[r.length-1];if(u.slice(0,p.length)==p){for(var v=1,n=a-r.length+1;v<r.length-1;v++)if(o(e.getLine(n+v))!=r[v])continue e;var b=e.getLine(a+1-r.length),x=o(b);if(x.slice(x.length-r[0].length)==r[0])return{from:g(a+1-r.length,c(b,x,b.length-r[0].length,o)),to:g(a,c(f,u,p.length,o))}}}}function d(e,t,i,a){this.atOccurrence=!1,this.doc=e,i=i?e.clipPos(i):g(0,0),this.pos={from:i,to:i};var c;"object"==typeof a?c=a.caseFold:(c=a,a=null),"string"==typeof t?(null==c&&(c=!1),this.matches=function(n,i){return(n?u:f)(e,t,i,c)}):(t=n(t),a&&!1===a.multiline?this.matches=function(n,i){return(n?l:o)(e,t,i)}:this.matches=function(n,i){return(n?s:r)(e,t,i)})}var h,m,g=e.Pos;String.prototype.normalize?(h=function(e){return e.normalize("NFD").toLowerCase()},m=function(e){return e.normalize("NFD")}):(h=function(e){return e.toLowerCase()},m=function(e){return e}),d.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(t){for(var n=this.matches(t,this.doc.clipPos(t?this.pos.from:this.pos.to));n&&0==e.cmpPos(n.from,n.to);)t?n.from.ch?n.from=g(n.from.line,n.from.ch-1):n=n.from.line==this.doc.firstLine()?null:this.matches(t,this.doc.clipPos(g(n.from.line-1))):n.to.ch<this.doc.getLine(n.to.line).length?n.to=g(n.to.line,n.to.ch+1):n=n.to.line==this.doc.lastLine()?null:this.matches(t,g(n.to.line+1,0));if(n)return this.pos=n,this.atOccurrence=!0,this.pos.match||!0;var i=g(t?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:i,to:i},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(t,n){if(this.atOccurrence){var i=e.splitLines(t);this.doc.replaceRange(i,this.pos.from,this.pos.to,n),this.pos.to=g(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},e.defineExtension("getSearchCursor",function(e,t,n){return new d(this.doc,e,t,n)}),e.defineDocExtension("getSearchCursor",function(e,t,n){return new d(this,e,t,n)}),e.defineExtension("selectMatches",function(t,n){for(var i=[],o=this.getSearchCursor(t,this.getCursor("from"),n);o.findNext()&&!(e.cmpPos(o.to(),this.getCursor("to"))>0);)i.push({anchor:o.from(),head:o.to()});i.length&&this.setSelections(i,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/scroll/annotatescrollbar",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){function n(e){clearTimeout(i.doRedraw),i.doRedraw=setTimeout(function(){i.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var i=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(i.doUpdate),i.doUpdate=setTimeout(function(){i.computeScale()&&n(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),!1!==t.listenForChanges&&e.on("change",this.changeHandler=function(){n(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.getScrollerElement().scrollHeight;if(t!=this.hScale)return this.hScale=t,!0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){function t(e,t){return s!=e.line&&(s=e.line,c=n.getLineHandle(s)),c.widgets&&c.widgets.length||a&&c.height>l?n.charCoords(e,"local")[t?"top":"bottom"]:n.heightAtLine(c,"local")+(t?0:c.height)}!1!==e&&this.computeScale();var n=this.cm,i=this.hScale,o=document.createDocumentFragment(),r=this.annotations,a=n.getOption("lineWrapping"),l=a&&1.5*n.defaultTextHeight(),s=null,c=null,f=n.lastLine();if(n.display.barWidth)for(var u,d=0;d<r.length;d++){var h=r[d];if(!(h.to.line>f)){for(var m=u||t(h.from,!0)*i,g=t(h.to,!1)*i;d<r.length-1&&!(r[d+1].to.line>f)&&!((u=t(r[d+1].from,!0)*i)>g+.9);)h=r[++d],g=t(h.to,!1)*i;if(g!=m){var p=Math.max(g-m,3),v=o.appendChild(document.createElement("div"));v.style.cssText="position: absolute; right: 0px; width: "+Math.max(n.display.barWidth-1,2)+"px; top: "+(m+this.buttonHeight)+"px; height: "+p+"px",v.className=this.options.className,h.id&&v.setAttribute("annotation-id",h.id)}}}this.div.textContent="",this.div.appendChild(o)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define("addon/search/matchesonscrollbar",["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n,i){this.cm=e,this.options=i;var o={listenForChanges:!1};for(var r in i)o[r]=i[r];o.className||(o.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(o),this.query=t,this.caseFold=n,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function n(e,t,n){return e<=t?e:Math.max(t,e+n)}e.defineExtension("showMatchesOnScrollbar",function(e,n,i){return"string"==typeof i&&(i={className:i}),i||(i={}),new t(this,e,n,i)});t.prototype.findMatches=function(){if(this.gap){for(var t=0;t<this.matches.length;t++){var n=this.matches[t];if(n.from.line>=this.gap.to)break;n.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var i=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),this.caseFold),o=this.options&&this.options.maxMatches||1e3;i.findNext();){var n={from:i.from(),to:i.to()};if(n.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,n),this.matches.length>o)break}this.gap=null}},t.prototype.onChange=function(t){var i=t.from.line,o=e.changeEnd(t).line,r=o-t.to.line;if(this.gap?(this.gap.from=Math.min(n(this.gap.from,i,r),t.from.line),this.gap.to=Math.max(n(this.gap.to,i,r),t.from.line)):this.gap={from:t.from.line,to:o+1},r)for(var a=0;a<this.matches.length;a++){var l=this.matches[a],s=n(l.from.line,i,r);s!=l.from.line&&(l.from=e.Pos(s,l.from.ch));var c=n(l.to.line,i,r);c!=l.to.line&&(l.to=e.Pos(c,l.to.ch))}clearTimeout(this.update);var f=this;this.update=setTimeout(function(){f.updateAfterChange()},250)},t.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},t.prototype.clear=function(){this.cm.off("change",this.changeHandler),this.annotation.clear()}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./matchesonscrollbar")):"function"==typeof define&&define.amd?define("addon/search/match-highlighter.js",["../../lib/codemirror","./matchesonscrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e){this.options={};for(var t in u)this.options[t]=(e&&e.hasOwnProperty(t)?e:u)[t];this.overlay=this.timeout=null,this.matchesonscroll=null,this.active=!1}function n(e){var t=e.state.matchHighlighter;(t.active||e.hasFocus())&&o(e,t)}function i(e){var t=e.state.matchHighlighter;t.active||(t.active=!0,o(e,t))}function o(e,t){clearTimeout(t.timeout),t.timeout=setTimeout(function(){l(e)},t.options.delay)}function r(e,t,n,i){var o=e.state.matchHighlighter;if(e.addOverlay(o.overlay=f(t,n,i)),o.options.annotateScrollbar&&e.showMatchesOnScrollbar){var r=n?new RegExp("\\b"+t+"\\b"):t;o.matchesonscroll=e.showMatchesOnScrollbar(r,!1,{className:"CodeMirror-selection-highlight-scrollbar"})}}function a(e){var t=e.state.matchHighlighter;t.overlay&&(e.removeOverlay(t.overlay),t.overlay=null,t.matchesonscroll&&(t.matchesonscroll.clear(),t.matchesonscroll=null))}function l(e){e.operation(function(){var t=e.state.matchHighlighter;if(a(e),!e.somethingSelected()&&t.options.showToken){for(var n=!0===t.options.showToken?/[\w$]/:t.options.showToken,i=e.getCursor(),o=e.getLine(i.line),l=i.ch,c=l;l&&n.test(o.charAt(l-1));)--l;for(;c<o.length&&n.test(o.charAt(c));)++c;return void(l<c&&r(e,o.slice(l,c),n,t.options.style))}var f=e.getCursor("from"),u=e.getCursor("to");if(f.line==u.line&&(!t.options.wordsOnly||s(e,f,u))){var d=e.getRange(f,u);t.options.trim&&(d=d.replace(/^\s+|\s+$/g,"")),d.length>=t.options.minChars&&r(e,d,!1,t.options.style)}})}function s(e,t,n){if(null!==e.getRange(t,n).match(/^\w+$/)){if(t.ch>0){var i={line:t.line,ch:t.ch-1},o=e.getRange(i,t);if(null===o.match(/\W/))return!1}if(n.ch<e.getLine(t.line).length){var i={line:n.line,ch:n.ch+1},o=e.getRange(n,i);if(null===o.match(/\W/))return!1}return!0}return!1}function c(e,t){return!(e.start&&t.test(e.string.charAt(e.start-1))||e.pos!=e.string.length&&t.test(e.string.charAt(e.pos)))}function f(e,t,n){return{token:function(i){if(i.match(e)&&(!t||c(i,t)))return n;i.next(),i.skipTo(e.charAt(0))||i.skipToEnd()}}}var u={style:"matchhighlight",minChars:2,delay:100,wordsOnly:!1,annotateScrollbar:!1,showToken:!1,trim:!0};e.defineOption("highlightSelectionMatches",!1,function(o,r,s){if(s&&s!=e.Init&&(a(o),clearTimeout(o.state.matchHighlighter.timeout),o.state.matchHighlighter=null,o.off("cursorActivity",n),o.off("focus",i)),r){var c=o.state.matchHighlighter=new t(r);o.hasFocus()?(c.active=!0,l(o)):o.on("focus",i),o.on("cursorActivity",n)}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define("addon/mode/multiplex.js",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.multiplexingMode=function(t){function n(e,t,n,i){if("string"==typeof t){var o=e.indexOf(t,n);return i&&o>-1?o+t.length:o}var r=t.exec(n?e.slice(n):e);return r?r.index+n+(i?r[0].length:0):-1}var i=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:e.startState(t),innerActive:null,inner:null}},copyState:function(n){return{outer:e.copyState(t,n.outer),innerActive:n.innerActive,inner:n.innerActive&&e.copyState(n.innerActive.mode,n.inner)}},token:function(o,r){if(r.innerActive){var a=r.innerActive,l=o.string;if(!a.close&&o.sol())return r.innerActive=r.inner=null,this.token(o,r);var s=a.close?n(l,a.close,o.pos,a.parseDelimiters):-1;if(s==o.pos&&!a.parseDelimiters)return o.match(a.close),r.innerActive=r.inner=null,a.delimStyle&&a.delimStyle+" "+a.delimStyle+"-close";s>-1&&(o.string=l.slice(0,s));var c=a.mode.token(o,r.inner);return s>-1&&(o.string=l),s==o.pos&&a.parseDelimiters&&(r.innerActive=r.inner=null),a.innerStyle&&(c=c?c+" "+a.innerStyle:a.innerStyle),c}for(var f=1/0,l=o.string,u=0;u<i.length;++u){var d=i[u],s=n(l,d.open,o.pos);if(s==o.pos)return d.parseDelimiters||o.match(d.open),r.innerActive=d,r.inner=e.startState(d.mode,t.indent?t.indent(r.outer,""):0),d.delimStyle&&d.delimStyle+" "+d.delimStyle+"-open";-1!=s&&s<f&&(f=s)}f!=1/0&&(o.string=l.slice(0,f));var h=t.token(o,r.outer);return f!=1/0&&(o.string=l),h},indent:function(n,i){var o=n.innerActive?n.innerActive.mode:t;return o.indent?o.indent(n.innerActive?n.inner:n.outer,i):e.Pass},blankLine:function(n){var o=n.innerActive?n.innerActive.mode:t;if(o.blankLine&&o.blankLine(n.innerActive?n.inner:n.outer),n.innerActive)"\n"===n.innerActive.close&&(n.innerActive=n.inner=null);else for(var r=0;r<i.length;++r){var a=i[r];"\n"===a.open&&(n.innerActive=a,n.inner=e.startState(a.mode,o.indent?o.indent(n.outer,""):0))}},electricChars:t.electricChars,innerMode:function(e){return e.inner?{state:e.inner,mode:e.innerActive.mode}:{state:e.outer,mode:t}}}}}),function(e){"function"==typeof e.define&&e.define("addons",["addon/comment/continuecomment.js","addon/edit/closebrackets.js","addon/edit/closetag.js","addon/edit/matchbrackets.js","addon/edit/matchtags.js","addon/edit/trailingspace.js","addon/fold/foldgutter.js","addon/fold/brace-fold.js","addon/fold/comment-fold.js","addon/fold/indent-fold.js","addon/format/autoFormatAll.js","addon/format/formatting.js","addon/selection/active-line.js","addon/search/match-highlighter.js","addon/mode/multiplex.js"],function(){})}(this);